#include<iostream>
#include<string>
#include<vector>

using namespace std;

struct TreeNode {
	int val;
	TreeNode* left;
	TreeNode* right;
	TreeNode() : val(0), left(nullptr), right(nullptr) {}
	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
	TreeNode(int x, TreeNode* left, TreeNode* right) : val(x), left(left), right(right) {}
};


class Solution {
public:
    void preorder(vector<string>& ret, TreeNode* root, string str)
    {
        if (root == nullptr)
        {
            return;
        }
        str += to_string(root->val) + "->";
        preorder(ret, root->left, str);
        preorder(ret, root->right, str);
        if (root->left == nullptr && root->right == nullptr)
        {
            str.pop_back(); str.pop_back();//删除最后那一个多余的箭头
            ret.push_back(str);
        }

    }
    vector<string> binaryTreePaths(TreeNode* root)
    {
        vector<string>ret;
        if (root == nullptr)return ret;
        string str;
        preorder(ret, root, str);
        return ret;
    }
};

int main()
{
	return 0;
}